//
//  LHTouristDetailViewController.m
//  Knight_Tour
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHTouristDetailViewController.h"
#import "LHTouristDetailUserView.h"
#import "MyNavgationView.h"
#import "LHDetailModel.h"
#import "LHCommonViewController.h"

@interface LHTouristDetailViewController ()<jumpToCommonDeledate>
@property (nonatomic ,retain)NSMutableArray *detailModelArr;
@end

@implementation LHTouristDetailViewController

- (void)dealloc
{
    [_detailModelArr release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.hidden = YES;
    self.detailModelArr = [NSMutableArray array];
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    [self getManagerWithCover];
    [self createTableView];
    [self createNavigation];
}
- (void)createTableView
{
    LHTouristDetailUserView *TDUV = [[LHTouristDetailUserView alloc] initWithFrame:self.view.bounds];
    TDUV.delegate = self;
    TDUV.modelArr = self.detailModelArr;
    [self.view addSubview:TDUV];
    [TDUV release];
}

- (void)createNavigation
{
    MyNavgationView *myNV = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    [myNV creatTitle:@"我的景点"];
    
    myNV.leftTarget = self;
    myNV.leftAction = @selector(backToUser);
    [myNV creatLeftButtonWithImage:@"btn_nav_back"];
    
    
    [self.view addSubview:myNV];
    [myNV release];
}

-(void) getManagerWithCover
{
    NSString *path = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"LHCountrySightDetail"] stringByAppendingPathComponent:@"LHCountrySightDetail.kk"];
    self.detailModelArr = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
}

-(void)jumpToCommon:(NSIndexPath *)index
{
    LHCommonViewController *vc = [[LHCommonViewController alloc]init];
    vc.model = self.detailModelArr[index.row];
    [self.navigationController pushViewController:vc animated:YES];
    [vc release];
}

- (void)backToUser
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
